#include<bits/stdc++.h>
using namespace std;
const int N=1e5+7,INF=1.1e9;
int n,rt,A,B,top,sta[N],fa[N],de[N],preA[N],f[N],g[N];
int dfn[N],tot,mxd[N],mnd[N],mnf[N],siz[N],a[N],c1[N],c2[N];
vector<int>G[N],Bson[N];
void dfs(int u,int f){
    sta[++top]=u,dfn[u]=++tot;
    mxd[u]=1,siz[u]=1,de[u]=de[f]+1,fa[u]=f;
    if(top>A)preA[u]=sta[top-A+1];
    else preA[u]=0;
    if(top>B)Bson[sta[top-B]].push_back(u);
    for(auto v:G[u]){
        if(v==f)continue;
        dfs(v,u);
        mxd[u]=max(mxd[u],mxd[v]+1);
        siz[u]+=siz[v];
    }
    top--;
    return;
}
struct seg{
    int tree[N<<2];
    void clear(){memset(tree,0,sizeof(tree));}
    void C(int k,int l,int r,int x,int y,int w){
        if(x<=l&&r<=y){
            tree[k]=max(tree[k],w);
            return;
        }
        int mid=(l+r)>>1;
        if(x<=mid)C(k<<1,l,mid,x,y,w);
        if(y>mid)C(k<<1|1,mid+1,r,x,y,w);
    }
    int ask(int k,int l,int r,int pos){
        if(l==r)return tree[k];
        int mid=(l+r)>>1;
        if(pos<=mid)return max(ask(k<<1,l,mid,pos),tree[k]);
        else return max(ask(k<<1|1,mid+1,r,pos),tree[k]);
    }
}T;
#define fi first
#define se second
void DFS(int u){
    f[u]=1,g[u]=0;
    if(a[u]) mnd[u]=de[u];
    else mnd[u]=INF;
    mnf[u]=INF;
    for(auto v:G[u]){
        if(v==fa[u])continue;
        DFS(v);
        mnd[u]=min(mnd[u],mnd[v]);
        mnf[u]=min(mnf[u],mnf[v]);
    }
    if(mxd[u]<=A)f[u]=(mnd[u]<=de[u]+B);
    if(f[u])mnf[u]=de[u];
    if(mnf[u]<=de[u]+B)g[u]=1;
    pair<int,int>_mxd={-INF,-INF},_mnd={INF,INF},_mnf={INF,INF};
    int Mxd,Mnd,Mnf;
    if(a[u])_mnd.fi=de[u];
    for(auto v:G[u]){
        if(v==fa[u]) continue;
        if(mxd[v]>=_mxd.fi)swap(_mxd.fi,_mxd.se),_mxd.fi=mxd[v];
        else _mxd.se=max(_mxd.se,mxd[v]);
        if(mnd[v]<=_mnd.fi)swap(_mnd.fi,_mnd.se),_mnd.fi=mnd[v];
        else _mnd.se=min(_mnd.se,mnd[v]);
        if(mnf[v]<=_mnf.fi)swap(_mnf.fi,_mnf.se),_mnf.fi=mnf[v];
        else _mnf.se=min(_mnf.se,mnf[v]);
    }
    for(auto v:G[u]){
        if(v==fa[u])continue;
        Mxd=(mxd[v]==_mxd.fi)?_mxd.se:_mxd.fi;
        Mnd=(mnd[v]==_mnd.fi)?_mnd.se:_mnd.fi;
        Mnf=(mnf[v]==_mnf.fi)?_mnf.se:_mnf.fi;
        int tmp=Mnf;
        if(Mxd<A&&Mnd-de[u]<=B)tmp=de[u];
        if(Mxd>=A&&c1[u]==c2[v])tmp=de[u];
        if(B>tmp-de[u])T.C(1,1,n,dfn[v],dfn[v]+siz[v]-1,de[u]+B-(tmp-de[u]));
    }
    for(auto v:Bson[u]){
        if(de[v]<=T.ask(1,1,n,dfn[v]))g[v]=1;
        if(!g[v]&&fa[preA[v]])f[fa[preA[v]]]=0,c1[fa[preA[v]]]++,c2[preA[v]]++;
    }
    return;
}
bool check(int num){
    for(int i=1;i<=n;i++)a[i]=(i<=num),c1[i]=0,c2[i]=0;
    T.clear();DFS(rt);
    return f[rt];
}
signed main(){
	freopen("nim.in","r",stdin);
	freopen("nim.out","w",stdout);
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin>>n>>rt>>A>>B;
    for(int i=1,u,v;i<n;i++){
        cin>>u>>v;
        G[u].push_back(v),G[v].push_back(u);
    }
    if(A<=B){
    	cout<<"1\n";
        return 0;
    }
    dfs(rt,0);
    int ans=n,l=1,r=n;
    while(l<=r){
    	int mid=(l+r)>>1;
        if(check(mid)){
            ans=mid;
            r=mid-1;
        }
        else l=mid+1;
    }
    cout<<ans<<"\n";
    return 0;
}
